package com.zoe.onelink.redis.property;

import com.zoe.onelink.redis.enumeration.RedisTemplateValueType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>标题: </p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2021</p>
 * <p>公司: 智业软件股份有限公司</p>
 *
 * @version: 1.0
 * @author: ruansheng
 * @date: 2021-09-11
 */
@Data
@ConfigurationProperties(prefix = RedisMultiDatasourceProperties.PROPERTY_PREFIX)
public class RedisMultiDatasourceProperties {

    public static final String PROPERTY_PREFIX = "spring.redis-multiple";

    private Map<String, RedisMultiProperties> datasourceMap = new HashMap<>(0);

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class RedisMultiProperties extends RedisProperties {

        private RedisTemplateValueType valueType = RedisTemplateValueType.OBJECT;

        private Class<? extends RedisSerializer<?>> keySerializer = StringRedisSerializer.class;

        private Class<? extends RedisSerializer<?>> valueSerializer = JdkSerializationRedisSerializer.class;

        private Class<? extends RedisSerializer<String>> hashKeySerializer = StringRedisSerializer.class;

        private Class<? extends RedisSerializer<?>> hashValueSerializer = StringRedisSerializer.class;

    }

}
